import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

const routes = [
  {
    path: "/",
    name: "RootView",
    component: () => import("../views/RootView.vue")
    //meta: { auth: true } // 设置当前路由需要校验  不需要校验的路由就不用写了；
  },
  {
    path: "/SignUpDetails",
    name: "SignUpDetails",
    component: () => import("../views/SignUpDetails.vue")
  },
  {
    path: "/SignUpFrom",
    name: "SignUpFrom",
    component: () => import("../views/SignUpFrom.vue")
  },
  {
    path: "/ShoppingCart",
    name: "ShoppingCart", //购物车
    component: () => import("../components/shopping/ShoppingCart.vue"),
    meta: { auth: true }
  },
  {
    path: "/ProductList",
    name: "ProductList", //商品列表
    component: () => import("../components/shopping/ProductList.vue")
  },
  {
    path: "/MyOrder",
    name: "MyOrder", //商品 我的订单
    component: () => import("../components/shopping/MyOrder.vue")
  },
  {
    path: "/ProductDetails",
    name: "ProductDetails", //商品详情页
    component: () => import("../components/shopping/ProductDetails.vue")
  },
  {
    path: "/Login",
    name: "Login", //登录
    component: () => import("../components/my/Login.vue")
  },
  {
    path: "/Register",
    name: "Register", //注册
    component: () => import("../components/my/Register.vue")
  },
  {
    path: "/ForgotPass",
    name: "ForgotPass", //忘记密码
    component: () => import("../components/my/ForgotPass.vue")
  },
  {
    path: "/Balance",
    name: "Balance",
    component: () => import("../components/my/Balance.vue")
  },
  {
    path: "/Friend",
    name: "Friend",
    component: () => import("../components/my/Friend.vue")
  },
  {
    path: "/MyClass",
    name: "MyClass",
    component: () => import("../components/my/MyClass.vue")
  },
  {
    path: "/Assistant",
    name: "Assistant",
    component: () => import("../components/my/Assistant.vue")
  },
  {
    path: "/VideoDetails",
    name: "VideoDetails",
    component: () => import("../components/signUp/VideoDetails.vue")
  },
  {
    path: "/Release",
    name: "Release", //发布
    component: () => import("../components/square/Release.vue")
  },
  {
    path: "/SquareDetails",
    name: "SquareDetails", //广场文章详情
    component: () => import("../components/square/SquareDetails.vue")
  },
  {
    path: "/MyInfor",
    name: "MyInfor", //修改个人信息
    component: () => import("../components/my/MyInfor.vue")
  },
  {
    path: "/PayAudit",
    name: "PayAudit", //支付审核
    component: () => import("../components/shopping/PayAudit.vue")
  },
  {
    path: "/ConsultApprove",
    name: "ConsultApprove", //商城认证
    component: () => import("../components/shopping/ConsultApprove.vue")
  },
  {
    path: "/OrderDetails",
    name: "OrderDetails", //商品 订单支付等待
    component: () => import("../components/shopping/OrderDetails.vue")
  },
  {
    path: "/SetUpInfo",
    name: "SetUpInfo", //个人中心 设置
    component: () => import("../components/my/SetUpInfo.vue")
  },
  {
    path: "/Agreement",
    name: "Agreement", //个人中心 协议
    component: () => import("../components/my/Agreement.vue")
  },
  {
    path: "/Distribution",
    name: "Distribution", //个人中心 跑腿配送
    component: () => import("../components/my/Distribution.vue")
  },
  {
    path: "/ShippingDetails",
    name: "ShippingDetails", //个人中心 配送详情
    component: () => import("../components/my/ShippingDetails.vue")
  },
  {
    path: "/ShippingPhotos",
    name: "ShippingPhotos", //个人中心 上传配送照片
    component: () => import("../components/my/ShippingPhotos.vue")
  },
  {
    path: "/InviteFriends",
    name: "InviteFriends", //分享
    component: () => import("../components/my/InviteFriends.vue")
  }
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes
});

export default router;
